/*
 * LafModel.java
 *
 * 08/11/2009
 */
package kg.sound.player.ui;

import java.util.ArrayList;
import java.util.List;

import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.skin.SkinInfo;

/**
 * @author fernando
 */
public class LafModel implements ComboBoxModel {

	private static final List<Info> SKINS = new ArrayList<Info>();

	private SkinInfo selectedSkin;

	public LafModel() {
		for (SkinInfo info : SubstanceLookAndFeel.getAllSkins().values()) {
			SKINS.add(new Info(info));
		}
	}

	@Override
	public Object getSelectedItem() {
		return selectedSkin;
	}

	@Override
	public void setSelectedItem(Object item) {
		this.selectedSkin = (Info) item;
	}

	@Override
	public Object getElementAt(int index) {
		return SKINS.get(index);
	}

	@Override
	public int getSize() {
		return SKINS.size();
	}

	@Override
	public void addListDataListener(ListDataListener l) {
		// nada a fazer
	}

	@Override
	public void removeListDataListener(ListDataListener l) {
		// nada a fazer
	}

	private class Info extends SkinInfo {

		private Info(SkinInfo skinInfo) {
			super(skinInfo.getDisplayName(), skinInfo.getClassName());
		}

		@Override
		public String toString() {
			return getDisplayName();
		}
	}
}
